import request from '@/utils/request'

export function getActivityList(name) {
	let query = new FormData()
	if (name.name != undefined) {
		query.append("name", name.name)
	}
	return request({
		headers: {
			"Content-Type": "multipart/form-data"
		},
		url: "/api/cms/subject/list",
		method: "POST",
		data: query
	})
}


export function createActivity(query) {
	return request({
		url: "/api/cms/subject/add",
		method: "POST",
		data: query
	})
}

export function getActivityInfo(id) {
	return request({
		url: `/api/cms/subject/updateInfo/${id}`,
		method: "GET"
	})
}

export function useAddProduct(msg) {
	let query = new FormData();
	let ids = msg.productId.toString();
	query.append("subjectId", msg.subjectId);
	query.append("productIds", ids);
	return request({
		headers: {
			"content-type": "multipart/form-data"
		},
		url: "/api/cms/subject/add/products",
		method: "POST",
		data: query
	})
}

export function updateActivity(id, query) {
	return request({
		url: `/api/cms/subject/update/${id}`,
		method: "POST",
		data: query
	})
}

export function getActiveProductList(id) {
	return request({
		url: "/api/cms/subject/product/list",
		method: "GET",
		params: {
			id: id
		}
	})
}

export function deleteActivity(id) {
	let query = new FormData();
	query.append("ids", id);
	return request({
		headers: {
			"content-type": "multipart/form-data"
		},
		url: "/api/cms/subject/delete",
		method: "POST",
		data: query
	})
}
